package br.com.aquinoevasconcelos.servlets.informativo;

import java.io.IOException;
import java.util.ArrayList;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import br.com.aquinoevasconcelos.fachada.Fachada;
import br.com.aquinoevasconcelos.modelos.Informativo;

/**
 * Servlet implementation class RemoverInformativo
 */
@WebServlet("/RemoverInformativo")
public class RemoverInformativo extends HttpServlet {
	private static final long serialVersionUID = 1L;

	public RemoverInformativo() {
		super();
	}

	protected void service(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {

		Fachada fachada = Fachada.getInstancia();
		Informativo info = new Informativo();
		
		String id = request.getParameter("id");
		info.setId(Long.parseLong(id));

		info.setId(Long.parseLong(request.getParameter("id")));

		try {
			fachada.removerInformativo(info);
			response.sendRedirect("ListaInformativo?msg=deletado");

		} catch (Exception e) {
			response.sendRedirect("pagina_erro/erro.jsp");

		}
	}

	protected void doGet(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
		service(request, response);
	}

	protected void doPost(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
		service(request, response);

	}

}
